<template>
  <div :style="outModuleCss">
    <div :style="moduleBgCss" class="module-bg"></div>
    <div class="topPic-section">
      <templateDefault
        v-if="propsData.params.styleType == 1"
        :propsData="propsData"
      ></templateDefault>
      <templateNews
        v-if="propsData.params.styleType == 2"
        :propsData="propsData"
        @handleNewsTab="handleNewsTab"
        @handleNewsTabItem="handleNewsTab"
      ></templateNews>
    </div>
  </div>
</template>

<script>
import topicLineOne from "@/assets/images/diy/toPic/topic_line_one.png";
import topicLineTwo from "@/assets/images/diy/toPic/topic_line_two.png";
import templateDefault from "./templates/default.vue";
import templateNews from "./templates/news.vue";
import { mixinsModuleCss } from "@/components/DiyNew/diy/mixins/index.js";

export default {
  name: "diyTopPic",
  components: {
    templateDefault,
    templateNews,
  },
  mixins: [mixinsModuleCss],
  props: {
    propsData: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {};
  },
  mounted() {
    console.log("组件挂载了：", this.propsData);
  },
  watch: {},
  computed: {
    topicImg() {
      if (this.propsData.params.styleType == 1) {
        if (this.propsData.params.topPicImg)
          return this.propsData.params.topPicImg;

        if (this.propsData.params.lineNum == 1) return topicLineOne;
        if (this.propsData.params.lineNum == 2) return topicLineTwo;
      }
    },
  },
  methods: {
    // 点击专题tab
    handleNewsTab(e) {
      this.$emit("chooseMoudle", e);
    },
    handleNewsTabItem(e) {
      this.$emit("chooseMoudle", e);
    },
  },
};
</script>

<style lang="scss" scoped>
.module-bg {
  width: 100%;
  height: 100%;
  z-index: -1;
  position: absolute;
  left: 0;
  top: 0;
}
.topPic-section {
  width: 100%;
  // background-color: #ffffff;
  border-radius: 8px;

  .template-default {
    width: 100%;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    overflow: hidden;
    .topic-img,
    .heigter-img {
      width: 76px;
      flex-shrink: 0;
      img {
        width: 100%;
      }
    }
    .heigter-img {
      width: 40px;
    }
    .topic-body {
      flex: 1;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      flex-direction: column;
      .topic-body-item {
        width: 100%;
        display: flex;
        align-items: center;
        margin-bottom: 4px;
        .topic-word {
          width: 224px;
          font-size: 14px;
          font-family: PingFang SC;
          font-weight: 400;
          color: #262626;
          padding: 0 6px 0 6px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          border-right: 1px solid #ebebeb;
          margin-bottom: 0;
          box-sizing: content-box;
        }
        .more {
          width: 40px;
          text-align: right;
          color: #888888;
          margin-bottom: 0;
        }
      }
      .topic-body-item:last-child {
        margin-bottom: 0;
      }
    }
  }
}
</style>
